package com.baseweb.webadmin.core.constants;

import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.List;

public enum CertificatesType {
    SHENFENGZHENG(1, "身份证"), JUNGUANZHENG(2, "军官证"), CANJIZHENG(3, "残疾证");

    private int code;
    private String name;

    CertificatesType(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static List<CertificatesType> getAllData() {
        List<CertificatesType> result = new ArrayList<CertificatesType>();
        for (CertificatesType current : CertificatesType.values()) {
            result.add(current);
        }
        return result;
    }

    public static List<CertificatesType> getCertificatesData(String authListStr) {
        List<CertificatesType> result = new ArrayList<CertificatesType>();

        for (CertificatesType current : CertificatesType.values()) {
            if (StringUtils.isBlank(authListStr) || authListStr.indexOf("" + current.getCode()) == -1) {
                result.add(current);
            }
        }
        return result;
    }

    public static CertificatesType getNameByCode(int code) {
        List<CertificatesType> allData = getAllData();
        for (CertificatesType status : allData) {
            if (status.getCode() == code) {
                return status;
            }
        }
        return null;
    }

    public static List<String> getTypeOpt() {
        List<String> list = new ArrayList<>();
        for (CertificatesType current : CertificatesType.values()) {
            String string = current.getCode() + ";" + current.getName();
            list.add(string);
        }
        return list;
    }
//    public static void main(String[] args) {
//        for(ChannelType c : getAllChannel()){
//            System.out.print(c.getName());
//        }
//    }
}
